package main

import (
	"fmt"
	"net"
)

import "packet"

func main() {
	conn, err := net.Dial("udp", "192.168.5.4:11110")
	defer conn.Close()
	packet.CheckError(err)

	pkt_send := packet.NPacket{Version: 1, ID: 1}
	copy(pkt_send.Buffer[:], "Ping")

	send_buff, err := packet.ConvertToBuffer(&pkt_send)
	packet.CheckError(err)

	conn.Write(send_buff)

	var recv_msg [4096]byte
	n, err := conn.Read(recv_msg[0:])
	packet.CheckError(err)

	pkt_recv, err := packet.ConvertToPacket(recv_msg[0:n])
	packet.CheckError(err)

	fmt.Println(pkt_recv)
}
